﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System.ComponentModel;


namespace MissedMemo.MeatAndCheeseDisc.BusinessLogic
{
    public class Address : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private string _addr1;
        private string _addr2;
        private string _city;
        private string _state;
        private string _zip;


    #region Properties...

        public string Addr1
        {
            get { return _addr1; }
            set
            {
                _addr1 = value;
                Notify( "Addr1" );
            }
        }

        public string Addr2
        {
            get { return _addr2; }
            set
            {
                _addr2 = value;
                Notify( "Addr2" );
            }
        }

        public string City
        {
            get { return _city; }
            set
            {
                _city = value;
                Notify( "City" );
            }
        }

        public string State
        {
            get { return _state; }
            set
            {
                _state = value;
                Notify( "State" );
            }
        }

        public string Zip
        {
            get { return _zip; }
            set
            {
                _zip = value;
                Notify( "Zip" );
            }
        }
    
    #endregion (Properties)

        
        internal Address Clone()
        {
            // Perform a shallow copy of all value fields...
            Address copy = (Address)MemberwiseClone();

            // Then, make deep copies of any reference fields...
            // (this class currently has none)

            return copy;
        }


        private void Notify( string strNotification )
        {
            if( PropertyChanged != null )
            {
                PropertyChanged( this, new PropertyChangedEventArgs( strNotification ) );
            }
        }
    }
}
